using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Media;

namespace MainGame.GameSound
{

  public enum GamePlaySounds
  {
    CardFlip1 = 0,
    CardFlip2 = 1,
    CardFlip3 = 2,
    CardFlip4 = 3,
    CardFlip5 = 4,
    PackPick1 = 5,
    PackPick2 = 6,
    PackPick3 = 7,
    Scopa = 8,
    NumSounds = 9
  }


  public class GamePlaySoundManager : SoundManager<GamePlaySounds>
  {
    public GamePlaySoundManager(Game game)
      : base(game) { }

    protected override void Dispose(bool disposing)
    {
      base.Dispose(disposing);
    }

    public override void Initialize()
    {
      soundLibrary = new SoundEffect[(int)GamePlaySounds.NumSounds];
      // Load all menu sounds
      var content = Game.Content;
      soundLibrary[(int)GamePlaySounds.CardFlip1] = content.Load<SoundEffect>(@"Sounds\\cardFlip1");
      soundLibrary[(int)GamePlaySounds.CardFlip2] = content.Load<SoundEffect>(@"Sounds\\cardFlip2");
      soundLibrary[(int)GamePlaySounds.CardFlip3] = content.Load<SoundEffect>(@"Sounds\\cardFlip3");
      soundLibrary[(int)GamePlaySounds.CardFlip4] = content.Load<SoundEffect>(@"Sounds\\cardFlip4");
      soundLibrary[(int)GamePlaySounds.CardFlip5] = content.Load<SoundEffect>(@"Sounds\\cardFlip5");
      soundLibrary[(int)GamePlaySounds.PackPick1] = content.Load<SoundEffect>(@"Sounds\\packPick1");
      soundLibrary[(int)GamePlaySounds.PackPick2] = content.Load<SoundEffect>(@"Sounds\\packPick2");
      soundLibrary[(int)GamePlaySounds.PackPick3] = content.Load<SoundEffect>(@"Sounds\\packPick3");
      soundLibrary[(int)GamePlaySounds.Scopa] = content.Load<SoundEffect>(@"Sounds\\Scopa");


      base.Initialize();
    }

    public override void PlaySound(GamePlaySounds sound)
    {
      if (!SfxMuted)
      {
        int snum = (int)sound;
        SoundEffectInstance sInst = soundLibrary[snum].CreateInstance();
        AddToPlayingQueue(sInst);
        sInst.Play();
      }
    }

    public override void PlaySound(GamePlaySounds sound, float volume, float pitch, float pan)
    {
      if (!SfxMuted)
      {
        int snum = (int)sound;
        SoundEffectInstance sInst = soundLibrary[snum].CreateInstance();
        AddToPlayingQueue(sInst);

        sInst.Volume = volume;
        sInst.Pitch = pitch;
        sInst.Pan = pan;

        sInst.Play();
      }
    }

  }
}
